/**
 * licenses
 *
 */
package com.openjawtech.xscraper.flights.domain;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * <p>an entity mapping to the flight table in db
 *
 * <p>15/02/2009
 * @author Wenbo.Sun
 */
@Entity
@Table(name = "flight")
public class Flight implements java.io.Serializable {
    private static final long serialVersionUID = 1L;


	private Integer flightId;
	private Airport airportByDepartureId;
	private Airport airportByArrivalId;
	private Date travelDate;
	private Double price;

	// Constructors

	/** default constructor */
	public Flight() {
	}

    public Flight(Integer flightId) {
        this.flightId = flightId;
    }

    public Flight(Date travelDate, Double price) {
        this.travelDate = travelDate;
        this.price = price;
    }

	/** minimal constructor */
	public Flight(Airport airportByDepartureId, Airport airportByArrivalId,
			Date travelDate) {
		this.airportByDepartureId = airportByDepartureId;
		this.airportByArrivalId = airportByArrivalId;
		this.travelDate = travelDate;
	}

	/** full constructor */
	public Flight(Airport airportByDepartureId, Airport airportByArrivalId,
			Date travelDate, Double price) {
		this.airportByDepartureId = airportByDepartureId;
		this.airportByArrivalId = airportByArrivalId;
		this.travelDate = travelDate;
		this.price = price;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "flight_id", unique = true, nullable = false)
	public Integer getFlightId() {
		return this.flightId;
	}

	public void setFlightId(Integer flightId) {
		this.flightId = flightId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "departure_id", nullable = false)
	public Airport getAirportByDepartureId() {
		return this.airportByDepartureId;
	}

	public void setAirportByDepartureId(Airport airportByDepartureId) {
		this.airportByDepartureId = airportByDepartureId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "arrival_id", nullable = false)
	public Airport getAirportByArrivalId() {
		return this.airportByArrivalId;
	}

	public void setAirportByArrivalId(Airport airportByArrivalId) {
		this.airportByArrivalId = airportByArrivalId;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "travel_date", nullable = false, length = 10)
	public Date getTravelDate() {
		return this.travelDate;
	}

	public void setTravelDate(Date travelDate) {
		this.travelDate = travelDate;
	}

	@Column(name = "price", precision = 10)
	public Double getPrice() {
		return this.price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

}